﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using WCFMastering.Contracts;
using WCFMastering.Services;

namespace WCFMastering.Host
{
    class Program
    {
        static void Main(string[] args)
        { 
            List<Type> serviceTypeList = new List<Type>() { 
                typeof(SimpleCalculator),
                typeof(ScientificCalculator),
                typeof(OneWayService),
                typeof(DuplexService)
            };
            List<ServiceHost> allServiceHosts = new List<ServiceHost>();

            foreach (Type serviceType in serviceTypeList)
            {
                ServiceHost host = new ServiceHost(serviceType);
                host.Open();
                Console.WriteLine(string.Format("Service:{0} has opened!",serviceType.Name));
                allServiceHosts.Add(host);
            }
            
            Console.ReadKey();
            foreach (ServiceHost host in allServiceHosts)
            {
                host.Close();
            }
        } 
    }
     
}
